package com.inco.cloud.server2;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;

//远程调用
@EnableFeignClients
//统一登陆
@EnableOAuth2Sso
//注册服务
@EnableDiscoveryClient
//扫描mapper
@MapperScan("com.**.*.mapper")
@SpringBootApplication(scanBasePackages = {"com.inco.cloud.common", "com.inco.cloud.server2"})
public class Server2Application {
    public static void main(String[] args) throws InterruptedException {

        ConfigurableApplicationContext applicationContext = SpringApplication.run(Server2Application.class, args);
        String userName = applicationContext.getEnvironment().getProperty("user.name");
        String userAge = applicationContext.getEnvironment().getProperty("user.age");
        String password = applicationContext.getEnvironment().getProperty("password");
        System.err.println("user name :"+userName+"; age: "+userAge+"; password："+password);
//        while(true) {
//            //当动态配置刷新时，会更新到 Enviroment中，因此这里每隔一秒中从Enviroment中获取配置
//            String userName = applicationContext.getEnvironment().getProperty("user.name");
//            String userAge = applicationContext.getEnvironment().getProperty("user.age");
//            String password = applicationContext.getEnvironment().getProperty("password");
//            System.err.println("user name :"+userName+"; age: "+userAge+"; password："+password);
//            TimeUnit.SECONDS.sleep(1);
//        }
    }
}